import api from '../../api';
import { message } from 'antd';
import { forEach } from 'lodash';

export default {
  namespace: 'SystemCalendarM',
  state: {
    resultDataObj: {
      config: {},
      performComp: {},
    }, //结果页数据
  },
  effects: {
    //获取日历汇总信息
    *queryCalendarList({ payload, callback }, { call, put }) {
      const response = yield call(api.SystemCalendar.getCalendarList, payload);

      if (response && response.code == 0) {
        callback('success', response.data.dataSource || []);
      } else {
        callback('fail');
        message.error(`获取系统日历信息失败，失败原因：${response?.msg}`);
        console.error(`获取系统日历信息失败，失败原因：${response?.msg}`, '接口名称： find 接口：portfolio-server/calendar-info/find');
      }
    },
  },

  reducers: {
    setState(state, { payload }) {
      return {
        ...state,
        ...payload,
      };
    },
  },
};
